/*
 * Copyright 2008 Nathan C Jones
 * 
 * This file is part of Fivehundred.
 * 
 * Fivehundred is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * Fivehundred is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * Fivehundred. If not, see <http://www.gnu.org/licenses/>. 
 */

package com.googlecode.fivehundred.ui;

import java.awt.Graphics2D;
import java.awt.Point;

import com.googlecode.fivehundred.ui.AbstractGraphicalComponent;

/**
 * A rectangular graphical component for use in unit tests.
 * 
 * @author Nathan C Jones
 */
class HelperRectangle extends AbstractGraphicalComponent {
	private int width, height;

	/** Create a square of width 10 positioned at location (0,0). */
	public HelperRectangle() {
		this(0, 0);
	}

	/**
	 * Create a rectangle with the given location and dimensions.
	 * 
	 * @param x the horizontal position of the rectangle.
	 * @param y the vertical position of the rectangle.
	 * @param width the width of the rectangle.
	 * @param height the height of the rectangle.
	 */
	public HelperRectangle(int x, int y, int width, int height) {
		this.setPosition(x, y);
		this.width = width;
		this.height = height;
	}

	/**
	 * Create a square of with 10 at the given location.
	 * 
	 * @param x the horizontal position of the new square.
	 * @param y the vertical position of the new square.
	 */
	public HelperRectangle(int x, int y) {
		this(x, y, 10, 10);
	}

	// not thread safe
	public boolean contains(Point p, int x, int y, double angle) {
		return p.x >= getPosition().x + x && p.x <= getPosition().x + x + width && p.y >= getPosition().y + y
				&& p.y <= getPosition().y + y + height;
	}

	public void paint(Graphics2D g, int x, int y, double angle) {
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}
}